﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace ViVa.ActiveDirectory
{
    public class Links
    {
        public string Link_Type { get; set; }
        public string Naam { get; set; }
        public string Omschrijving { get; set; }
        public string Link_Url { get; set; }

        public static void addLink(Links link)
        {
            link.Naam = link.Naam.Replace("'", "''");
            link.Link_Url = link.Link_Url.Replace("'", "''");
            link.Omschrijving = link.Omschrijving.Replace("'", "''");

            string query = "INSERT INTO Links (Link_Type, Naam, Link_Url, Omschrijving) " +
                       "VALUES ('" + link.Link_Type + "','" + link.Naam + "','" + link.Link_Url + "','" + link.Omschrijving + "')";
            Database.insertQueryDatabase(query);
        }

        public static DataTable getLinks()
        {
            string query = "SELECT * FROM Links";
            SqlDataReader reader = Database.queryDatabase(query);
            return Helper.ConvertSqlDataReaderToDataTable(reader);
        }

        public static void verwijderLink(Links link)
        {
            string query = "DELETE FROM Links " +
                            "WHERE Naam = '" + link.Naam + "'";
            Database.insertQueryDatabase(query);
        }
    }
}
